package com.aiobc.file.config;

import com.aiobc.file.intercept.DomainInterceptor;
import com.aiobc.file.intercept.ValidPreInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author wangjun18 2020/3/8
 * @version v1.0.0
 */
@Configuration
public class FileUploadMVCConfigurer implements WebMvcConfigurer {

    @Autowired
    private DomainInterceptor domainInterceptor;

    @Autowired
    private ValidPreInterceptor validPreInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(domainInterceptor);
        registry.addInterceptor(validPreInterceptor).addPathPatterns("/*").addPathPatterns("/*/**")
                .excludePathPatterns("/error/**", "/swagger-ui.html/**", "/v2/**", "/webjars/**",
                        "/swagger-resources/**", "/configuration/**")
                .excludePathPatterns("/enum/**");
    }
}
